<%@ page language="java" contentType="text/html; charset=UTF-8" %>
<%@ page import="com.weavernorth.humanresource.AutoLogin" %>
<%@ page import="weaver.hrm.User" %>
<%@ page import="weaver.integration.util.SessionUtil" %>
<%@ page import="weaver.general.BaseBean" %>
<%@ page import="weaver.general.Util" %>
<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%
    BaseBean bb = new BaseBean();
//    bb.writeLog("人事自助跳转页面");
//    User user_new = null;
//    AutoLogin autoLogin = new AutoLogin();
//
//    String strPhone = Util.null2String(request.getParameter("phone"));
//    bb.writeLog("测试电话号码:"+strPhone);
//    String strUid = autoLogin.createUserSessionAndGetDispatcherUrl(strPhone);
//    //OA有相关人员
//    User user = (User) request.getSession(true).getAttribute("weaver_user@bean");
//    if (user == null) {
//        bb.writeLog("用户session还未构造，新登录");
//    } else if ((user != null && !user.getLoginid().equals("rzry"))) {
//        bb.writeLog("老用户session=" + user.getLoginid() + " 新用户session=" + "rzry");
//    }
//    if (user == null || (user != null && !user.getLoginid().equals("rzry"))) {
//        // 人员还未登录，构造人员
//        SessionUtil.createSession(strUid, request, response);
//    } else {
//        // 人员已登录
//        user_new = user;
//    }
//    //session构建后查询当前人员的requestid
//    String strRequestid = autoLogin.getRequestid(strUid);
//    bb.writeLog("当前入职人员的流程id"+strRequestid);
//    String strRequestUrl="/spa/workflow/static4form/index.html?_rdm=1575251636288#/main/workflow/req?requestid="+strRequestid;
//    bb.writeLog("当前请求流程路径"+strRequestUrl);
//     response.sendRedirect(strRequestUrl);


String strDate="2020-01-01";
String strDwId=request.getParameter("id");


    RecordSet rs = new RecordSet();
    //得到年份
    int intYear = Integer.parseInt(strDate.split("-")[0]);
    //当前日期
    Date date = new Date();
    SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
    String strCurr = format.format(date);
    //当前月份
    String strCurrMonth = strCurr.split("-")[1];

    //返回信息
    String strBs = "";
    //在有效期内的
    String sql = "select * from uf_dwjczb where id=? and  yxksrq<=? and yxjsrq>=?";
    //判断是否需要全年的编码
    bb.writeLog("查询淡旺季:" + sql + ",id:" + strDwId + ",strDate:" + strDate);
    rs.executeQuery(sql, strDwId, strDate, strDate);
    while (rs.next()) {
        //开始月份
        int intKsyf = Util.getIntValue(rs.getString("ksyf"));
        //开始年月日
        String strBeginDate = String.valueOf(intYear) + "-" + String.format("%02d", Integer.valueOf(intKsyf)) + "-01";
        //结束月份
        int intJsyf = Util.getIntValue(rs.getString("jsyf"));
        //结束日期
        String strEndDate  = String.valueOf(intYear) + "-" + String.format("%02d", Integer.valueOf(intJsyf)) + "-01";
        //淡旺季标识
        String strDwj = Util.null2String(rs.getString("dwj"));
        //是否跨年
        String strSfkn = Util.null2String(rs.getString("sfkn"));
        bb.writeLog("是否跨年:"+strSfkn);
        //如果跨年,则结束月份年份加1
        if ("1".equals(strSfkn)) {
            bb.writeLog("开始月份:"+intKsyf);
            bb.writeLog("当前月份:"+strCurrMonth);
            bb.writeLog("年份:"+intYear);
            //跨年的话,再比较当前月份是否小于开始月份
            if (intKsyf > Integer.parseInt(strCurrMonth)) {
                strBeginDate = String.valueOf(intYear - 1) + "-" + String.format("%02d", Integer.valueOf(intKsyf)) + "-01";
            }else {
                strEndDate = String.valueOf(intYear + 1) + "-" + String.format("%02d", Integer.valueOf(intJsyf)) + "-01";
            }
        }
        bb.writeLog("开始日期:" + strBeginDate + ",结束日期:" + strEndDate + ",传入标识:" + strDate);
        //返回不在当前月份的编号
        if (!(strBeginDate.compareTo(strDate) <= 0 && strEndDate.compareTo(strDate) >= 0)) {
            bb.writeLog("返回淡旺季标识:" + strDwId);
           // return strDwId;
        }

    }





%>